/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Consultar.java
 *
 * Created on 02/11/2011, 12:00:14
 */
package Interfaces;

import classes.Agenda;
import classes.AreaTematica;
import classes.EventoPrincipal;
import classes.Minicurso;
import classes.Painel;
import classes.Palestrante;
import classes.Recurso;
import conexaoBD.mySQLcrud;
import java.awt.Color;
import java.awt.Dimension;
import java.security.Timestamp;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import javax.swing.DefaultListModel;
import javax.swing.JOptionPane;
import javax.swing.ListModel;

/**
 *
 * @author Kazuo
 */
public class TelaExibicaoAtividadePainel extends javax.swing.JFrame {

    private mySQLcrud connectionCrud;
    private ArrayList<EventoPrincipal> listaEventosPrincipal;
    private ArrayList<AreaTematica> areaTema;
    Dimension s = new Dimension(59, 20);
    Dimension s2 = new Dimension(120, 20);
   private ArrayList<Recurso> listaRecursosSelecionados;
    private ArrayList<Palestrante> listaPalestranteSelecionados;

    /** Creates new form Consultar */
    public TelaExibicaoAtividadePainel(String codigo) {
        connectionCrud = new mySQLcrud();
        initComponents();
        cbEventoPrincipal.setPreferredSize(s);
        cbAreaCiencia.setPreferredSize(s);
        cbTema.setPreferredSize(s);
        txtNome.setPreferredSize(s2);
        txtInstituicao.setPreferredSize(s2);
        txtNomeMod.setPreferredSize(s2);

        ArrayList<Painel> exibe = new ArrayList<Painel>();
        exibe = connectionCrud.listaPainel("");

        preencheTabelaExibicao(exibe, Integer.parseInt(codigo));

    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        java.awt.GridBagConstraints gridBagConstraints;

        jPanel1 = new javax.swing.JPanel();
        lblTitulo = new javax.swing.JLabel();
        lblParamConsulta = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        btConfirmar = new javax.swing.JButton();
        btCancelar = new javax.swing.JButton();
        btRecursos1 = new javax.swing.JButton();
        jScrollPane4 = new javax.swing.JScrollPane();
        listRecursos3 = new javax.swing.JList();
        jScrollPane5 = new javax.swing.JScrollPane();
        listPalestrantes = new javax.swing.JList();
        btApresentadores = new javax.swing.JButton();
        btConfirmar1 = new javax.swing.JButton();
        lblNome = new javax.swing.JLabel();
        txtNome = new javax.swing.JTextField();
        lblNumVagas = new javax.swing.JLabel();
        txtNumVagas = new javax.swing.JTextField();
        cbEventoPrincipal = new javax.swing.JComboBox();
        lblInstituicao = new javax.swing.JLabel();
        lblNomeMod = new javax.swing.JLabel();
        lblEventoPrincipal = new javax.swing.JLabel();
        lblDataInicio = new javax.swing.JLabel();
        lblDataTermino = new javax.swing.JLabel();
        lblArea = new javax.swing.JLabel();
        txtNomeMod = new javax.swing.JTextField();
        lblNome1 = new javax.swing.JLabel();
        txtInstituicao = new javax.swing.JTextField();
        jDateInicio = new com.toedter.calendar.JDateChooser();
        jDateTermino = new com.toedter.calendar.JDateChooser();
        cbAreaCiencia = new javax.swing.JComboBox();
        cbTema = new javax.swing.JComboBox();
        jLabel1 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        lblTitulo.setFont(new java.awt.Font("Tahoma", 1, 14));
        lblTitulo.setText("Dados da");
        jPanel1.add(lblTitulo);

        lblParamConsulta.setFont(new java.awt.Font("Tahoma", 1, 16));
        lblParamConsulta.setText("Atividade - Painel");
        jPanel1.add(lblParamConsulta);

        jPanel2.setLayout(new java.awt.GridBagLayout());

        btConfirmar.setText("Cancelar");
        btConfirmar.setToolTipText("Cancelar e retornar para a tela anterior");
        btConfirmar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btConfirmarActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 3;
        gridBagConstraints.gridy = 12;
        gridBagConstraints.insets = new java.awt.Insets(15, 0, 0, 0);
        jPanel2.add(btConfirmar, gridBagConstraints);

        btCancelar.setText("Remover Atividade");
        btCancelar.setToolTipText("Clique aqui para remover a Atividade");
        btCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btCancelarActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 12;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        gridBagConstraints.insets = new java.awt.Insets(15, 0, 0, 0);
        jPanel2.add(btCancelar, gridBagConstraints);

        btRecursos1.setText("Editar Recursos");
        btRecursos1.setToolTipText("Clique aqui para editar Recursos");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 9;
        gridBagConstraints.insets = new java.awt.Insets(8, 0, 8, 0);
        jPanel2.add(btRecursos1, gridBagConstraints);

        listRecursos3.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { " ", " ", " ", " ", " " };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        listRecursos3.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        listRecursos3.setToolTipText("Lista de Recursos");
        jScrollPane4.setViewportView(listRecursos3);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 10;
        gridBagConstraints.ipadx = 120;
        jPanel2.add(jScrollPane4, gridBagConstraints);

        listPalestrantes.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { " ", " ", " ", " " };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        listPalestrantes.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        listPalestrantes.setToolTipText("Lista de Apresentadores");
        jScrollPane5.setViewportView(listPalestrantes);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 10;
        gridBagConstraints.gridwidth = 2;
        gridBagConstraints.ipadx = 120;
        jPanel2.add(jScrollPane5, gridBagConstraints);

        btApresentadores.setText("Editar Apresentadores");
        btApresentadores.setToolTipText("Clique aqui para editar Apresentadores");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 9;
        gridBagConstraints.gridwidth = 2;
        jPanel2.add(btApresentadores, gridBagConstraints);

        btConfirmar1.setText("Salvar Alterações");
        btConfirmar1.setToolTipText("Salvar alterações da Atividade");
        btConfirmar1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btConfirmar1ActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 12;
        gridBagConstraints.insets = new java.awt.Insets(15, 0, 0, 0);
        jPanel2.add(btConfirmar1, gridBagConstraints);

        lblNome.setText("Título:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 5);
        jPanel2.add(lblNome, gridBagConstraints);

        txtNome.setToolTipText("Digite o título do Painel");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.ipadx = 153;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        jPanel2.add(txtNome, gridBagConstraints);

        lblNumVagas.setText("Número de Vagas:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 5);
        jPanel2.add(lblNumVagas, gridBagConstraints);

        txtNumVagas.setToolTipText("Informe o número de vagas para esta atividade");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 3;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.ipadx = 153;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        jPanel2.add(txtNumVagas, gridBagConstraints);

        cbEventoPrincipal.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        cbEventoPrincipal.setToolTipText("Selecione a Workshop que se encontra a atividade");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.ipadx = 103;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        jPanel2.add(cbEventoPrincipal, gridBagConstraints);

        lblInstituicao.setText("Instituição Moderador:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 7;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        jPanel2.add(lblInstituicao, gridBagConstraints);

        lblNomeMod.setText("Nome Moderador:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 6;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        gridBagConstraints.insets = new java.awt.Insets(20, 0, 0, 0);
        jPanel2.add(lblNomeMod, gridBagConstraints);

        lblEventoPrincipal.setText("Workshop:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 5);
        jPanel2.add(lblEventoPrincipal, gridBagConstraints);

        lblDataInicio.setText("Data de Início:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 5);
        jPanel2.add(lblDataInicio, gridBagConstraints);

        lblDataTermino.setText("Data de Término:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 5);
        jPanel2.add(lblDataTermino, gridBagConstraints);

        lblArea.setText("Área da Ciência:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 8;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        jPanel2.add(lblArea, gridBagConstraints);

        txtNomeMod.setToolTipText("Insira o nome do Moderador");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 6;
        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.ipadx = 153;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(20, 0, 0, 0);
        jPanel2.add(txtNomeMod, gridBagConstraints);

        lblNome1.setText("Tema:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 8;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        jPanel2.add(lblNome1, gridBagConstraints);

        txtInstituicao.setToolTipText("Insira a instituição do moderador");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 7;
        gridBagConstraints.gridwidth = 3;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.ipadx = 153;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        jPanel2.add(txtInstituicao, gridBagConstraints);

        jDateInicio.setPreferredSize(new java.awt.Dimension(56, 20));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.ipadx = 12;
        jPanel2.add(jDateInicio, gridBagConstraints);

        jDateTermino.setPreferredSize(new java.awt.Dimension(56, 20));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 3;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        jPanel2.add(jDateTermino, gridBagConstraints);

        cbAreaCiencia.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cbAreaCienciaItemStateChanged(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 8;
        gridBagConstraints.ipadx = 103;
        jPanel2.add(cbAreaCiencia, gridBagConstraints);

        cbTema.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        cbTema.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cbTemaItemStateChanged(evt);
            }
        });
        cbTema.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                cbTemaKeyTyped(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 3;
        gridBagConstraints.gridy = 8;
        gridBagConstraints.ipadx = 103;
        jPanel2.add(cbTema, gridBagConstraints);

        jLabel1.setForeground(new java.awt.Color(255, 0, 0));
        jLabel1.setText("Atenção: Todos os campos são obrigatórios!");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 3;
        gridBagConstraints.gridy = 0;
        jPanel2.add(jLabel1, gridBagConstraints);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, 777, Short.MAX_VALUE)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 777, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 408, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btConfirmarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btConfirmarActionPerformed
        this.setVisible(false);
    }//GEN-LAST:event_btConfirmarActionPerformed

    private void btConfirmar1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btConfirmar1ActionPerformed
        JOptionPane.showMessageDialog(null, "Alterações realiazdas com sucesso");
        this.setVisible(false);
    }//GEN-LAST:event_btConfirmar1ActionPerformed

    private void btCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btCancelarActionPerformed
        JOptionPane.showMessageDialog(null, "Remoção realiazda com sucesso");
        this.setVisible(false);
    }//GEN-LAST:event_btCancelarActionPerformed

    private void cbAreaCienciaItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbAreaCienciaItemStateChanged
        String itemSelecionado = (String) cbAreaCiencia.getSelectedItem();
        if (!itemSelecionado.equals("Selecione a area da ciência")) {
            //preencherComboBoxAreaTema(itemSelecionado);
        }
}//GEN-LAST:event_cbAreaCienciaItemStateChanged

    private void cbTemaItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbTemaItemStateChanged

}//GEN-LAST:event_cbTemaItemStateChanged

    private void cbTemaKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_cbTemaKeyTyped
        // TODO add your handling code here:
}//GEN-LAST:event_cbTemaKeyTyped

        public void setListaRecursosSelecionados(ArrayList<Recurso> listaRecursosObj) {
        listaRecursosSelecionados = listaRecursosObj;
        DefaultListModel listaRecursosModel = new DefaultListModel();

        for (Recurso r : listaRecursosObj) {
            listaRecursosModel.addElement(r.getNomeRecurso());
        }
        listRecursos3.setModel(listaRecursosModel);
    }

    public void setListaPalestrantesSelecionados(ArrayList<Palestrante> listaPalestranteObj) {
        listaPalestranteSelecionados = listaPalestranteObj;
        DefaultListModel listaRecursosModel = new DefaultListModel();

        for (Palestrante r : listaPalestranteObj) {
            listaRecursosModel.addElement(r.getNomePalestrante());
        }
        listPalestrantes.setModel(listaRecursosModel);
    }


    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new TelaConsulta().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btApresentadores;
    private javax.swing.JButton btCancelar;
    private javax.swing.JButton btConfirmar;
    private javax.swing.JButton btConfirmar1;
    private javax.swing.JButton btRecursos1;
    private javax.swing.JComboBox cbAreaCiencia;
    private javax.swing.JComboBox cbEventoPrincipal;
    private javax.swing.JComboBox cbTema;
    private com.toedter.calendar.JDateChooser jDateInicio;
    private com.toedter.calendar.JDateChooser jDateTermino;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JLabel lblArea;
    private javax.swing.JLabel lblDataInicio;
    private javax.swing.JLabel lblDataTermino;
    private javax.swing.JLabel lblEventoPrincipal;
    private javax.swing.JLabel lblInstituicao;
    private javax.swing.JLabel lblNome;
    private javax.swing.JLabel lblNome1;
    private javax.swing.JLabel lblNomeMod;
    private javax.swing.JLabel lblNumVagas;
    private javax.swing.JLabel lblParamConsulta;
    private javax.swing.JLabel lblTitulo;
    private javax.swing.JList listPalestrantes;
    private javax.swing.JList listRecursos3;
    private javax.swing.JTextField txtInstituicao;
    private javax.swing.JTextField txtNome;
    private javax.swing.JTextField txtNomeMod;
    private javax.swing.JTextField txtNumVagas;
    // End of variables declaration//GEN-END:variables

    private void preencheTabelaExibicao(ArrayList<Painel> exibe, Integer codigo) {
        ArrayList<Painel> listaPainel = new ArrayList<Painel>();
        int indice = 0;
        for (Object o : exibe) {
            listaPainel.add((Painel) o);
        }
        for (int i = 0; i < exibe.size(); i++) {
            if (listaPainel.get(i).getCodPainel() == codigo) {
                indice = i;
            }
        }

        txtNomeMod.setText(listaPainel.get(indice).getNomeModerador());
        txtInstituicao.setText(listaPainel.get(indice).getInstituicaoModerador());
    }
}
